package com.ruoyi.project.system.controller;


import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.CollegePaperAnswer;
import com.ruoyi.project.system.service.ICollegePaperAnswerService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 学院试卷答题Controller
 * 
 * @author ruoyi
 * @date 2020-11-19
 */
@RestController
@RequestMapping("/system/answer")
public class CollegePaperAnswerController extends BaseController
{
    @Autowired
    private ICollegePaperAnswerService collegePaperAnswerService;

    /**
     * 查询学院试卷答题列表
     */
    @PreAuthorize("@ss.hasPermi('system:answer:list')")
    @GetMapping("/list")
    public TableDataInfo list(CollegePaperAnswer collegePaperAnswer)
    {
        startPage();
        List<Map<String,Object>> list = collegePaperAnswerService.selectCollegePaperAnswerList(collegePaperAnswer);
        return getDataTable(list);
    }

//    /**
//     * 导出学院试卷答题列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:answer:export')")
//    @Log(title = "学院试卷答题", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(CollegePaperAnswer collegePaperAnswer)
//    {
//        List<CollegePaperAnswer> list = collegePaperAnswerService.selectCollegePaperAnswerList(collegePaperAnswer);
//        ExcelUtil<CollegePaperAnswer> util = new ExcelUtil<CollegePaperAnswer>(CollegePaperAnswer.class);
//        return util.exportExcel(list, "answer");
//    }

    /**
     * 获取学院试卷答题详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:answer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(collegePaperAnswerService.selectCollegePaperAnswerById(id));
    }

    /**
     * 新增学院试卷答题
     */
    @Log(title = "学院试卷答题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollegePaperAnswer collegePaperAnswer)
    {
        return toAjax(collegePaperAnswerService.insertCollegePaperAnswer(collegePaperAnswer));
    }

    /**
     * 修改学院试卷答题
     */
    @PreAuthorize("@ss.hasPermi('system:answer:edit')")
    @Log(title = "学院试卷答题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollegePaperAnswer collegePaperAnswer)
    {
        return toAjax(collegePaperAnswerService.updateCollegePaperAnswer(collegePaperAnswer));
    }

    /**
     * 删除学院试卷答题
     */
    @PreAuthorize("@ss.hasPermi('system:answer:remove')")
    @Log(title = "学院试卷答题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(collegePaperAnswerService.deleteCollegePaperAnswerByIds(ids));
    }
}
